#include "TTSEngine.h"

AudioLogger* TTSEngine::m_pAudioLogger = NULL;

TTSEngine::TTSEngine(TTSEngineType type)
{
	m_engineType = type;
	m_pConfigurator = UIConfigResourceManager::getInstance();
	m_pLogger		= UILogger::getInstance();
	m_isInitialized = false;
}

TTSEngine::~TTSEngine(void)
{
	if (m_pAudioLogger)
		delete m_pAudioLogger;
}

AudioLogger* TTSEngine::getTTSAudioLogger(void) {
	if (m_pAudioLogger)
		return m_pAudioLogger;

	bool enableLogging = false;
	UIConfigResourceManager::getInstance()->getBoolValue(MODULE_SpeechManager, "tts-log", "tts.enableLog", enableLogging);
	if (enableLogging) {
		AudioFormat logFormat;
		UIConfigResourceManager::getInstance()->getIntValue(MODULE_SpeechManager, "tts-log", "tts.samplerate", logFormat.nSampleRate);
		UIConfigResourceManager::getInstance()->getIntValue(MODULE_SpeechManager, "tts-log", "tts.bits", logFormat.nBits);
		UIConfigResourceManager::getInstance()->getIntValue(MODULE_SpeechManager, "tts-log", "tts.channel", logFormat.nChannels);
		UIConfigResourceManager::getInstance()->getStringValue(MODULE_SpeechManager, "tts-log", "tts.encoding", logFormat.encoding);
		UIConfigResourceManager::getInstance()->getStringValue(MODULE_SpeechManager, "tts-log", "tts.endian", logFormat.endian);
		UIConfigResourceManager::getInstance()->getStringValue(MODULE_SpeechManager, "tts-log", "tts.type", logFormat.type);
		m_pAudioLogger = new AudioLogger(logFormat);
	}
	return m_pAudioLogger;
}